<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户管理</title>
<link rel="stylesheet" type="text/css" href="../css/default.css">
<link rel="stylesheet" type="text/css"
	href="../js/jquery-easyui-1.3.5/themes/gray/easyui.css">
<script type="text/javascript"
	src="../js/jquery-easyui-1.3.5/jquery-1.10.2.min.js"></script>
<link rel="stylesheet" type="text/css"
	href="../../easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="../../easyui/demo/demo.css">
<script type="text/javascript" src="../../easyui/jquery.min.js"></script>
<script type="text/javascript" src="../../easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="../../easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../js/extends.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script>
	$(function() {
		$("#tt").datagrid({
			height : $("#body").height() - $('#search_area').height() - 5,
			width : $("#body").width(),
			idField : 'id',
			//data: data,
			url : "../../meettingaddress/findByPage.do",
			method : 'get',
			singleSelect : true,
			nowrap : true,
			fitColumns : true,
			rownumbers : true,
			showPageList : false,
			columns : [ [ {
				field : 'address',
				title : '地址',
				width : 100,
				halign : "center",
				align : "center"
			} ] ],
			toolbar : '#tt_btn',
			pagination : true,
			onDblClickRow : function(rowIndex, rowData) {
				viewDetail(rowData.userId);
			}
		});

		//新增弹出框
		$("#add").on("click", function() {
			$("#dialog").dialog("open").dialog('setTitle', '新增');
			$("#addform").form("clear");
			url = "../../meettingaddress/saveMeettingaddress.do";
			document.getElementById("hidtype").value = "submit";

		});
		//修改
		$("#update").on("click", function() {
			var row = $('#tt').datagrid('getSelected');
			if (row) {
				$("#dialog").dialog("open").dialog('setTitle', '修改');
				$("#addform").form("clear");
				url = "../../meettingaddress/updateMeettingaddress.do";
				document.getElementById("hidtype").value = "submit";
				$("#addform").form("load", row);
			}
		});
		//删除
		$("#delete")
				.on(
						"click",
						function() {
							var row = $('#tt').datagrid('getSelected');
							if (row) {
								$.messager
										.confirm(
												'提示',
												'确定删除选中的记录?',
												function(r) {
													if (r) {
														$
																.post(
																		'../../meettingaddress/deleteMeettingaddress.do',
																		{
																			id : row.id
																		},
																		function(
																				result) {
																			if ("1" == result) {
																				$.messager
																						.alert(
																								"提示信息",
																								"删除成功");
																				$(
																						"#tt")
																						.datagrid(
																								'reload');
																			} else {
																				$.messager
																						.alert(
																								"提示信息",
																								"删除失败");
																				$(
																						"#add")
																						.dialog(
																								"close");
																			}
																		},
																		'json');
													}
												});
							}
						});

		$("#addMeettingaddress_cancel").on("click", function() {
			$("#parent_win").window("close");
		});
	})

	//保存
	function save() {
		$("#addform").form("submit", {
			url : url,
			onsubmit : function() {
				return $(this).form("validate");
			},
			success : function(result) {
				if ("1" == result) {
					$.messager.alert("提示信息", "操作成功");
					$("#dialog").dialog("close");
					$("#tt").datagrid("load");
				} else {
					$.messager.alert("提示信息", "操作失败");
					$("#dialog").dialog("close");
					$("#tt").datagrid("load");
				}
			}
		});
	}

	//查询
	function query() {
		$('#tt').datagrid('reload', {
			'address' : $("#address").val(),
		});

	}

	//重置
	function reset() {
		$("#queryform").form("clear");
	}

	function viewDetail(date, id) {
		$parent.messager.alert("提示", "查询详细", "info");
	}

	//监听窗口大小变化
	window.onresize = function() {
		setTimeout(domresize, 300);
	};
	//改变表格宽高
	function domresize() {
		$('#tt').datagrid('resize', {
			height : $("#body").height() - $('#search_area').height() - 5,
			width : $("#body").width()
		});
	}
</script>
</head>
<body class="easyui-layout">
	<div id="body" region="center">
		<!-- 查询条件区域 -->
		<div id="search_area">
			<div id="conditon">
				<form action="" id="queryform" method="post">
					<table border="0">
						<tr>
							<td>地址：</td>
							<td><input name="address" id="address" /></td>
							<td><a href="javascript:void(0)"
								class="easyui-linkbutton my-search-button" iconCls="icon-search"
								plain="true" onclick="query()">查询</a> <a
								href="javascript:void(0)"
								class="easyui-linkbutton my-search-button" iconCls="icon-reset"
								plain="true" onclick="reset()">重置</a></td>
						</tr>
					</table>
				</form>
			</div>
			<span id="openOrClose">111</span>
		</div>
		<!-- 数据表格区域 -->
		<table id="tt" style="table-layout: fixed;"></table>
		<!-- 表格顶部工具按钮 -->
		<div id="tt_btn">
			<a href="javascript:void(0)" id="add" class="easyui-linkbutton"
				iconCls="icon-add" plain="true">新增</a> <a href="javascript:void(0)"
				id="update" class="easyui-linkbutton" iconCls="icon-edit"
				plain="true">修改</a> <a href="javascript:void(0)" id="delete"
				class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a>
		</div>
	</div>
	<div id="dialog" class="easyui-dialog" closed="true"
		buttons="#dlg-buttons" data-options="closed:true,modal:true"
		style="width: 350px; height: 250px; padding: 5px;">
		<div class="ftitle">地址详情</div>
		<form id="addform" name="form" method="post"
			style="margin: 0px auto; text-align: center; padding: 10px;">
			<div class="content">
				<table width="280" border="0" align="center" cellpadding="3">
					<tr>
						<td width="80" align="right"><label for="address"><span
								class="x">*</span>地址：</label></td>
						<td width="200"><input type="text" name="address"
							id="address" /></td>
					</tr>
				</table>
			</div>
			<!-- 弹出框按钮 -->
			<div class="windowButton">
				<a id="addMeettingaddress_add"
					class="easyui-linkbutton my-dialog-button" plain="true"
					icon="icon-ok" href="javascript:void(0)" onclick="save()">保存</a> <a
					id="addMeettingaddress_cancel"
					class="easyui-linkbutton my-dialog-button" plain="true"
					icon="icon-cancel" href="javascript:void(0)">取消</a>
			</div>
			<input type="hidden" name="action" id="hidtype" /><input
				type="hidden" name="id">
		</form>
	</div>
</body>
</html>
